package com.enthusiasm.frame;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;

import com.enthusiasm.constants.SoundManager;
import com.enthusiasm.view.GameWaveView;

public class GameWaveActivity extends Activity{

	public static int id;
	private GameWaveView gameView;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		id = getIntent().getIntExtra("id", 0);
		gameView = new GameWaveView(this, id);
		setContentView(gameView);
	}
	
	@Override
	protected void onResume() {
		super.onResume();
		if(SoundManager.getInstance(this).getIsMediaStop() == false)
			SoundManager.getInstance(this).resumeBackGroundSound();
	}
	
	@Override
	protected void onPause() {
		super.onPause();
		gameView.wavingThread.setRunning(false);
		SoundManager.getInstance(this).pauseBackgroundSound();
	}
	
	@Override
	protected void onDestroy() {
		super.onDestroy();
	}
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
			gameView.wavingThread.setRunning(false);
			Intent intent = new Intent(this,GameCollectActivity.class);
			startActivity(intent);
			finish();
			overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out);
		}
		return super.onKeyDown(keyCode, event);
	}
}
